﻿using System;
using System.Collections.Generic;
#if DEBUG
using System.Diagnostics;
#endif // #if DEBUG
using System.Linq;
using System.Text;
using System.Data.Objects.DataClasses;

using FRL.DebtChased.Repository.ViewModels;

namespace FRL.DebtChased.Repository
{

	/// <summary>
	/// Extensions to the AccountTradingStyle model
	/// </summary>
	public partial class AccountTradingStyle
	{

		/////////////////////////////////////////////////////////////
		// Static operations

		public static Dictionary<int, string> GetDictionary(DebtChasedEntities ent, bool bAddNotSetOption)
		{

			// Declare return variable
			Dictionary<int, string> Ftmp = new Dictionary<int, string>();

			// If adding not-set option...
			if (bAddNotSetOption)
				Ftmp.Add(0, Definitions.NotSet);

			// Load the users
			var styleList = from ats in ent.AccountTradingStyles
							orderby ats.Name
							select new { ats.AccountTradingStyleId, ats.Name };
			foreach( var di in styleList)
				Ftmp.Add(di.AccountTradingStyleId, di.Name);

			// Return variable
			return Ftmp;

		}

		public static string GetName(DebtChasedEntities ent, int iStyleId)
		{

			// Look up trading style name
			return (from ats in ent.AccountTradingStyles where ats.AccountTradingStyleId == iStyleId select ats.Name).FirstOrDefault();

		}

	}

}
